package com.chj.security;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.chj.entity.UserInfo;

public class SecurityUser implements UserDetails {

	private static final long serialVersionUID = 1L;

	public SecurityUser() {
	}

	public SecurityUser(UserInfo loginUser) {
		super();
		this.loginUser = loginUser;
	}

	private UserInfo loginUser;

	public UserInfo getLoginUser() {
		return loginUser;
	}

	public void setLoginUser(UserInfo loginUser) {
		this.loginUser = loginUser;
	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		List<SimpleGrantedAuthority> list = new ArrayList<SimpleGrantedAuthority>();
		list.add(new SimpleGrantedAuthority("ROLE_" + loginUser.getRole()));
		return list;
	}

	@Override
	public String getPassword() {
		return loginUser.getAuthpwd();
	}

	@Override
	public String getUsername() {
		return loginUser.getUsername();
	}

	@Override
	public boolean isAccountNonExpired() {
		return false;
	}

	@Override
	public boolean isAccountNonLocked() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isEnabled() {
		// TODO Auto-generated method stub
		return false;
	}

}
